<?php
function timenum($time){//计算时间的函数
        $startdate=date('Y-m-d',$time);
        $enddate=date('Y-m-d');
        $str='';
        $year=floor((strtotime($enddate)-strtotime($startdate))/86400/365);
        $mo=floor((strtotime($enddate)-strtotime($startdate))/86400/30);
        $mo=$mo>30?0:$mo;
        $date=floor((strtotime($enddate)-strtotime($startdate))/86400);
        $date=$date>=365?0:$date;
        $hour=floor((strtotime($enddate)-strtotime($startdate))%86400/3600);
        $minute=floor((strtotime($enddate)-strtotime($startdate))%86400/60);
        $second=floor((strtotime($enddate)-strtotime($startdate))%86400%60);
        
        if($year>0){
                    return $year."年前上传";
                }
                if($mo>0){
                    return $mo.'个月前上传';
                }
                if($date>0){
                    return $date.'天前上传';
                }
                if($hour>0){
                    return $hour.'小时前上传';
                }
                if($minute>0){
                    return $minute.'分钟前上传'; 
                }
                if($second>0){
                    return '刚刚上传';
                }
        
        
        
}
?>